<?php

	function serviceGET($request) {
		$service = new Service();
		
		$getById = false;
		if (!(!$request->getArgs || $request->getArgs['id'] == "")) {
			$service->setServiceId($request->getArgs['id']);
			$getById = true;
		}
		
		
		$serviceBusiness = BusinessFactory::factory('ServiceBusiness');
		$result = $serviceBusiness->select($service);
		
		if ($result != NULL) {
		
			if(is_array($result)) {
				if($getById) {
					if (sizeof($result) == 1) {
						header("Status: 200 Success", true, 200);
						return $result[0];
					}
					else {
						header("Status: 404 Not Found", true, 404);
					}
				}
				else {
					header("Status: 200 Success", true, 200);
					return $result;
				}
				
				
			} else {
				header("Status: 500 Internal Server Error", true, 500);
			}
		}
		else {
			header("Status: 500 Internal Server Error", true, 500);
		} 
		
		return $result;
	}

?>